import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '缺陷Id',
    align: "center",
    sorter: true,
    dataIndex: 'defectId'
  },
  {
    title: '项目名称',
    align: "center",
    sorter: true,
    dataIndex: 'projectId_dictText'
  },
  {
    title: '系统名称',
    align: "center",
    sorter: true,
    dataIndex: 'systemId_dictText'
  },
  {
    title: '众测批次',
    align: "center",
    sorter: true,
    dataIndex: 'batchId_dictText'
  },
  {
    title: '模块名称',
    align: "center",
    dataIndex: 'moduleName'
  },
  {
    title: '功能点',
    align: "center",
    sorter: true,
    dataIndex: 'functionName'
  },
  {
    title: '缺陷等级',
    align: "center",
    dataIndex: 'defectLevel_dictText'
  },
  {
    title: '缺陷类型',
    align: "center",
    sorter: true,
    dataIndex: 'defectType_dictText'
  },
  {
    title: '缺陷描述',
    align: "center",
    sorter: true,
    dataIndex: 'defectTitle'
  },
  {
    title: '轮次名称',
    align: "center",
    sorter: true,
    dataIndex: 'testStage_dictText'
  },
  {
    title: '环境',
    align: "center",
    sorter: true,
    dataIndex: 'envType_dictText'
  },
  {
    title: '缺陷优先级',
    align: "center",
    sorter: true,
    dataIndex: 'defectPriority_dictText'
  },
  {
    title: '缺陷提出人',
    align: "center",
    sorter: true,
    dataIndex: 'ownerId_dictText'
  },
  {
    title: '提出时间',
    align: "center",
    sorter: true,
    dataIndex: 'commitTime'
  },
  {
    title: '缺陷状态',
    align: "center",
    sorter: true,
    dataIndex: 'bugStatus_dictText'
  },
  {
    title: '缺陷处理人',
    align: "center",
    sorter: true,
    dataIndex: 'solverId_dictText'
  },
  {
    title: '是否有影响',
    align: "center",
    sorter: true,
    dataIndex: 'isInfects_dictText'
  },
  {
    title: '影响范围',
    align: "center",
    sorter: true,
    dataIndex: 'infects'
  },
  {
    title: '不解决原因',
    align: "center",
    sorter: true,
    dataIndex: 'noSloveReason'
  },
  {
    title: '缺陷原因',
    align: "center",
    sorter: true,
    dataIndex: 'defectReason'
  },
  {
    title: '原因分类',
    align: "center",
    sorter: true,
    dataIndex: 'defectReasonCata_dictText'
  },
  {
    title: '修复时间',
    align: "center",
    sorter: true,
    dataIndex: 'fixTime'
  },
  {
    title: '解决时间',
    align: "center",
    sorter: true,
    dataIndex: 'resolveTime'
  },
  {
    title: '关闭时间',
    align: "center",
    sorter: true,
    dataIndex: 'closeTime'
  },
  {
    title: '是否重新开启',
    align: "center",
    sorter: true,
    dataIndex: 'isReopen_dictText'
  },
  {
    title: '重启次数',
    align: "center",
    sorter: true,
    dataIndex: 'reopenTimes'
  },
  {
    title: '缺陷图片',
    align: "center",
    sorter: true,
    dataIndex: 'defectImg',
    customRender: render.renderImage,
  },
  {
    title: '备注',
    align: "center",
    sorter: true,
    dataIndex: 'commets'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "项目名称",
    field: 'projectId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project,project_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "系统名称",
    field: 'systemId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project_system,system_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "众测批次",
    field: 'batchId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_crowd_test_plan where pid='0',plan_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "模块名称",
    field: 'systemModuleId',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "缺陷类型",
    field: 'defectType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "defect_type"
    },
    //colProps: {span: 6},
  },
  {
    label: "轮次名称",
    field: 'testStage',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_test_stage,test_stage_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "缺陷优先级",
    field: 'defectPriority',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "defect_priority"
    },
    //colProps: {span: 6},
  },
  {
    label: "缺陷提出人",
    field: 'ownerId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_user,realname,username"
    },
    //colProps: {span: 6},
  },
  {
    label: "提出时间",
    field: 'commitTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
    },
    //colProps: {span: 6},
  },
  {
    label: "缺陷状态",
    field: 'bugStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "bug_status"
    },
    //colProps: {span: 6},
  },
  {
    label: "缺陷处理人",
    field: 'solverId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_user,realname,username"
    },
    //colProps: {span: 6},
  },
  {
    label: "严重程度",
    field: 'severity',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "severity"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '项目名称',
    field: 'projectId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project,project_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目名称!'},
             ];
    },
  },
  {
    label: '系统名称',
    field: 'systemId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project_system,system_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入系统名称!'},
             ];
    },
  },
  {
    label: '众测批次',
    field: 'batchId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_crowd_test_plan where pid='0',plan_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入众测批次!'},
             ];
    },
  },
  {
    label: '模块名称',
    field: 'moduleName',
    component: 'Input',
  },
  {
    label: '功能点',
    field: 'functionName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入功能点!'},
             ];
    },
  },
  {
    label: '缺陷等级',
    field: 'defectLevel',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "defect_level"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入缺陷等级!'},
             ];
    },
  },
  {
    label: '缺陷类型',
    field: 'defectType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "defect_type"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入缺陷类型!'},
             ];
    },
  },
  {
    label: '缺陷描述',
    field: 'defectTitle',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入缺陷描述!'},
             ];
    },
  },
  {
    label: '操作步骤',
    field: 'description',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入操作步骤!'},
             ];
    },
  },
  {
    label: '轮次名称',
    field: 'testStage',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_test_stage,test_stage_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入轮次名称!'},
             ];
    },
  },
  {
    label: '环境',
    field: 'envType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "env_type"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入环境!'},
             ];
    },
  },
  {
    label: '缺陷优先级',
    field: 'defectPriority',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "defect_priority"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入缺陷优先级!'},
             ];
    },
  },
  {
    label: '缺陷提出人',
    field: 'ownerId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_user,realname,username"
    },
  },
  {
    label: '缺陷状态',
    field: 'bugStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "bug_status"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入缺陷状态!'},
             ];
    },
  },
  {
    label: '缺陷处理人',
    field: 'solverId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_user,realname,username"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入缺陷处理人!'},
             ];
    },
  },
  {
    label: '是否有影响',
    field: 'isInfects',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "yn"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入是否有影响!'},
             ];
    },
  },
  {
    label: '影响范围',
    field: 'infects',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入影响范围!'},
             ];
    },
  },
  {
    label: '不解决原因',
    field: 'noSloveReason',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入不解决原因!'},
             ];
    },
  },
  {
    label: '缺陷原因',
    field: 'defectReason',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入缺陷原因!'},
             ];
    },
  },
  {
    label: '原因分类',
    field: 'defectReasonCata',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "defect_reason_cata"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入原因分类!'},
             ];
    },
  },
  {
    label: '缺陷图片',
    field: 'defectImg',
    component: 'JImageUpload',
    componentProps:{
    },
  },
  {
    label: '备注',
    field: 'commets',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  defectId: {title: '缺陷Id',order: 0,view: 'text', type: 'string',},
  projectId: {title: '项目名称',order: 1,view: 'sel_search', type: 'string',dictTable: "tm_project", dictCode: 'id', dictText: 'project_name',},
  systemId: {title: '系统名称',order: 2,view: 'sel_search', type: 'string',dictTable: "tm_project_system", dictCode: 'id', dictText: 'system_name',},
  batchId: {title: '众测批次',order: 3,view: 'sel_search', type: 'string',dictTable: "tm_crowd_test_plan where pid='0'", dictCode: 'id', dictText: 'plan_name',},
  moduleName: {title: '模块名称',order: 5,view: 'text', type: 'string',},
  functionName: {title: '功能点',order: 6,view: 'text', type: 'string',},
  defectLevel: {title: '缺陷等级',order: 7,view: 'list', type: 'string',dictCode: 'defect_level',},
  defectType: {title: '缺陷类型',order: 8,view: 'list', type: 'string',dictCode: 'defect_type',},
  defectTitle: {title: '缺陷描述',order: 9,view: 'textarea', type: 'string',},
  testStage: {title: '轮次名称',order: 11,view: 'sel_search', type: 'string',dictTable: "tm_test_stage", dictCode: 'id', dictText: 'test_stage_name',},
  envType: {title: '环境',order: 12,view: 'list', type: 'string',dictCode: 'env_type',},
  defectPriority: {title: '缺陷优先级',order: 13,view: 'list', type: 'string',dictCode: 'defect_priority',},
  ownerId: {title: '缺陷提出人',order: 14,view: 'sel_search', type: 'string',dictTable: "sys_user", dictCode: 'username', dictText: 'realname',},
  commitTime: {title: '提出时间',order: 15,view: 'datetime', type: 'string',},
  bugStatus: {title: '缺陷状态',order: 16,view: 'list', type: 'string',dictCode: 'bug_status',},
  solverId: {title: '缺陷处理人',order: 17,view: 'sel_search', type: 'string',dictTable: "sys_user", dictCode: 'username', dictText: 'realname',},
  isInfects: {title: '是否有影响',order: 18,view: 'list', type: 'string',dictCode: 'yn',},
  infects: {title: '影响范围',order: 19,view: 'textarea', type: 'string',},
  noSloveReason: {title: '不解决原因',order: 20,view: 'textarea', type: 'string',},
  defectReason: {title: '缺陷原因',order: 21,view: 'textarea', type: 'string',},
  defectReasonCata: {title: '原因分类',order: 22,view: 'list', type: 'string',dictCode: 'defect_reason_cata',},
  fixTime: {title: '修复时间',order: 23,view: 'datetime', type: 'string',},
  resolveTime: {title: '解决时间',order: 24,view: 'datetime', type: 'string',},
  closeTime: {title: '关闭时间',order: 25,view: 'datetime', type: 'string',},
  isReopen: {title: '是否重新开启',order: 27,view: 'list', type: 'string',dictCode: 'yes_or_no',},
  reopenTimes: {title: '重启次数',order: 28,view: 'number', type: 'number',},
  defectImg: {title: '缺陷图片',order: 29,view: 'image', type: 'string',},
  commets: {title: '备注',order: 30,view: 'textarea', type: 'string',},
};
